package com.bear.fastrepair.mvvm.ui.employee.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import com.bear.fastrepair.R
import com.bear.fastrepair.databinding.DialogImageBinding
import com.bear.fastrepair.entity.BitmapInfo
import com.bumptech.glide.Glide

class ImageDialog(context: Context, private val bitmap: BitmapInfo) :
    Dialog(context, R.style.Dialog) {
    private lateinit var binding: DialogImageBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DialogImageBinding.inflate(LayoutInflater.from(context))
        setContentView(binding.root)
        setCancelable(true)
        bitmap.let {
            when {
                it.file != null -> {
                    Glide.with(context).load(it.file).into(binding.dialogImage)
                }
                it.resId != null -> {
                    Glide.with(context).load(it.resId).into(binding.dialogImage)
                }
                it.uri != null -> {
                    Glide.with(context).load(it.uri).into(binding.dialogImage)
                }
                it.url != null -> {
                    Glide.with(context).load(it.url).into(binding.dialogImage)
                }
                else -> Unit
            }
        }
    }
}